/*
 * MIT License
 *
 * Copyright (c) 2020 wen.gu <454727014@qq.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/***************************************************************************
 * Name: mp_data_source.h
 *
 * Purpose: the date source comnponent for micro player
 *
 * Developer:
 *   wen.gu , 2018-09-03
 *
 * TODO: 
 *
 ***************************************************************************/
#ifndef __MP_DATA_SOURCE_H__
#define __MP_DATA_SOURCE_H__

/******************************************************************************
**    INCLUDES
******************************************************************************/
#include "mp_component.h"
#include "mp_types.h"
/******************************************************************************
**    MACROS
******************************************************************************/


/******************************************************************************
**    TYPE DEFINITIONS
******************************************************************************/

/******************************************************************************
**    CLASSES/FUNCTIONS DEFINITIONS
******************************************************************************/


class MPDataSource: public MPComponent
{
public:
    MPDataSource(const std::string& name, const std::string& version);
    ~MPDataSource();

public:
    virtual MPError connect() = 0;
    virtual MPError disconnect() = 0;

    /**
     * return: really read size,if error then return -1,
     */
    virtual int32_t read(void* buffer, uint32_t size) = 0;
    /** set position(start from the begin of 'file')*/
    virtual int64_t seek(int64_t position) = 0;
    /** move position from current read pointer(just move, don't read) */
    virtual int64_t skip(int64_t offset) = 0;
    virtual int64_t tell() = 0;
    virtual int64_t size() = 0;
    virtual MPError getLastError(){return mLastError; }

protected:
    MPError mLastError = MP_OK;
};

#endif /** !__MP_DATA_SOURCE_H__*/


 

